package com.air.designmodel.six.strategy.handler;

import com.air.designmodel.six.common.CommonPairResponse;
import com.air.designmodel.six.common.FormSubmitRequest;
import com.air.designmodel.six.strategy.FormSubmitHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Serializable;

/**
 * 模型输入时提交
 *
 * @author shent
 */
public class FormModelSubmitHandler implements FormSubmitHandler<Serializable> {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Override
    public String getSubmitType() {
        return "model";
    }

    @Override
    public CommonPairResponse<String, Serializable> handleSubmit(FormSubmitRequest request) {
        logger.info("模型输入模式提交:userId:{},formInput={}", request.getUserId(), request.getFormInput());
        //模型创建成功后获得模型id
        Long modelId = createModel(request);
        return CommonPairResponse.success("模型输入模式提交数据成功!", modelId);
    }

    private Long createModel(FormSubmitRequest request) {
        //创建模型逻辑
        return 123L;
    }
}
